/**
 * 神州信息(2012)
 */
package net.abbp.report.view.cell.editor;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.JToolBar;
import javax.swing.SwingUtilities;

import net.abbp.report.model.ReportModel;
import net.abbp.report.view.GridView;

import com.reportgear.core.swing.pane.base.EditorPane;

/**
 * 子报表设计面板
 * 
 * @version 1.0
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since ABBP 1.0
 * 
 *        <pre>
 * 历史：
 *      建立: 2012-7-22 lexloo
 * </pre>
 */
public class SubReportDesignPane extends EditorPane<ReportModel> {
    private static final long serialVersionUID = 3220629099651528147L;
    // 当前视图
    private GridView view;

    public SubReportDesignPane() {
        this.setLayout(new BorderLayout());

        view = new GridView(ReportModel.EMPTY_MODEL);
        view.setGridActionMenu(new SubReportContextMenu());
        this.add(view);

        JToolBar tlbMain = new SubReportToolBar();
        this.add(tlbMain, BorderLayout.NORTH);
    }

    @Override
    public void populate(ReportModel value) {
        this.view.setReportModel(value);
    }

    @Override
    public ReportModel update() {
        return this.view.getReportModel();
    }

    /**
     * 获取当前视图
     * 
     * @return 当前视图
     */
    public GridView getGridView() {
        return this.view;
    }

    @Override
    public int showDialog(Component owner) {
        return this.showDialog(SwingUtilities.getWindowAncestor(owner), "子报表", 800, 600);
    }
}
